//
//  HNNewFestuerChose.m
//  HappyNews
//
//  Created by baiping on 16/1/9.
//  Copyright © 2016年 BPWBANP. All rights reserved.
//

#import "HNNewFestuerChose.h"
#import "HNRootTabBarViewController.h"
#import "HNNewfeatureViewController.h"

@implementation HNNewFestuerChose

+ (void)choseRootViewController{
    
    // 取出版本号的字符串
    NSString *key = @"CFBundleVersion";
    
    // 取出沙盒中存储的上次使用软件的版本号
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *lastVersion = [defaults stringForKey:key];
    
    // 获得当前软件的版本号
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
    if ([currentVersion isEqualToString:lastVersion]) {
        // 显示状态栏
        [UIApplication sharedApplication].statusBarHidden = NO;
        [UIApplication sharedApplication].keyWindow.rootViewController = [[HNRootTabBarViewController alloc] init];
    } else { // 新版本
        
        [UIApplication sharedApplication].statusBarHidden = YES;
        
        [UIApplication sharedApplication].keyWindow.rootViewController = [[HNNewfeatureViewController alloc] init];
        // 存储新版本
        [defaults setObject:currentVersion forKey:key];
        // 同步存储
        [defaults synchronize];
    }

}

@end
